Unit xpTABLE;

{$mode objfpc}{$H+}

Interface

Uses
  Crt,
  EnA;

Var
  Level, EXP,
  Count : Integer;
  LevelledUp : Boolean;

Procedure XpGiver(Var EXP : Integer; EXPReward : Integer);
Procedure Leveller(Var Level, EXP : Integer; ClassType : String; Var HP, Strength, Wisdom, MP, Agility : Integer);
Procedure SkillUp(ClassType : String; Var HP, Strength, Wisdom, MP, Agility : Integer);

Implementation

Procedure XpGiver(Var EXP : Integer; EXPReward : Integer);
Begin
  EXP := EXP + (EXPReward + XpBoost);
end;

Procedure SkillUp(ClassType : String; Var HP, Strength, Wisdom, MP, Agility : Integer);
Begin
  HP := HP + 40;

  If ClassType = 'Warrior' then
    Begin
      Strength := Strength + 1;
      Writeln('Strength increased by 1, to: ',Strength);
      Writeln('HP increased to: ',HP);
    end;

  If ClassType = 'Mage' then
    Begin
      Wisdom := Wisdom + 1;
      MP := MP + 35;
      Writeln('Wisdom increased by 1, to: ',Wisdom);
      Writeln('HP increased to: ',HP);
      Writeln('Mana Increased to: ',MP);
    end;

  If ClassType = 'Archer' then
    Begin
      Agility := Agility + 1;
      Writeln('Strength increased by 1, to: ',Agility);
      Writeln('HP increased to: ',HP);
    end;
end;

Procedure Leveller(Var Level, EXP : Integer; ClassType : String; Var HP, Strength, Wisdom, MP, Agility : Integer);
Var
  PreviousLevel : Integer;
Begin
  LevelledUp := False;

  PreviousLevel := Level;

  If EXP >= 5 then
    Level := 2;
  If EXP >= 10 then
    Level := 3;
  If EXP >= 20 then
    Level := 4;
  If EXP >= 35 then
    Level := 5;
  If EXP >= 60 then
    Level := 6;
  If EXP >= 90 then
    Level := 7;
  If EXP >= 150 then
    Level := 8;
  If EXP >= 270 then
    Level := 9;
  If EXP >= 400 then
    Level := 10;

  If Level > PreviousLevel then
    Begin
      Writeln('You levelled up!');
      Writeln('You are now Level ',Level);
      LevelledUp := True;
    end;

  Writeln;

  If LevelledUp then
    SkillUp(ClassType, Hp, Strength, Wisdom, Mp, Agility);

  Writeln;
  If (LevelledUp) and (Level = 3) then
    Writeln('You learned a new ability!');
  If (LevelledUp) and (Level = 5) then
    Writeln('You learned a new ability!');
  If (LevelledUp) and (Level = 7) then
    Writeln('You learned a new ability!');
  If (LevelledUp) and (Level = 9) then
    Writeln('You learned a new ability!');
  If (LevelledUp) and (Level = 10) then
    Writeln('You learned a new ability!');

end;

end.


